/**
 * [description]
 * @author lu.hong 2016-09-09
 * @param  {[type]} $translate) {                  var CodeMirror [description]
 * @param  {[type]} p);                         	}                              };    return codeEditorService;}] [description]
 * @return {[type]}             [description]
 */
angular.module('app').factory('codeEditorService', ['$translate', function($translate) {
    var CodeMirror = require('codemirror');
    var codeEditorService = {
    	init : function(id,opts){
			var defs = {//标识到textarea
				//value : "http://www.cnblogs.com/oldphper",  // 文本域默认显示的文本
				theme : 'neo',//CSS样式选择
				mode: "cypher",//模式 text/html javascript
				indentUnit : 2,  //缩进单位，默认2
				smartIndent : true,  //是否智能缩进
				tabSize : 4,  //Tab缩进，默认4
				readOnly : false,  //是否只读，默认false
				showCursorWhenSelecting : true,
				lineWrapping: true,
				indentWithTabs: false,
				styleActiveLine: true, //line选择是是否加亮
				matchBrackets: true,
				lineNumbers : true //是否显示行号
			};
			var p = $.extend({}, defs, opts);//合并对象
			return CodeMirror.fromTextArea(document.getElementById(id),p);
		}
	};
    return codeEditorService;
}]);